import schedule
import rss_parser
import datetime
import time
import rss_config

def job():
    print('begin get news ...')
    rss_parser.parse_news()

def log_time():
    now = datetime.datetime.now()
    format_time = now.strftime('%Y-%m-%d %H:%M:%S')
    print(f'{format_time} | scheduler is running ...')

if __name__ == '__main__':
    print('rss scheduler start ...')
    schedule.every().minute.do(log_time)
    # do job every minute
    # schedule.every().minute.do(job)
    # do job at costom time
    # schedule.every().day.at('08:00').do(job)
    # schedule.every().day.at('13:00').do(job)
    # schedule.every().day.at('18:00').do(job)
    # read job time from config
    for job_time in rss_config.job_run_times:
        schedule.every().day.at(job_time).do(job)

    while True:
        schedule.run_pending()
        time.sleep(1)
